//
//  BillColtroller.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/9/5.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "BillColtroller.h"

#import "BillCell1.h"

#import "BillCell2.h"

#import "LinegraphCell.h"

@interface BillColtroller ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView * tableView;
@end

@implementation BillColtroller

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.tableView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self setUpNavi];
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

-(void)setUpNavi{
    [super setUpNavi];
    self.navigationItem.title = @"月账单";
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if(section == 0) return 2;
    if(section == 1) return 1;
    if(section == 2) return 2;
    return 0;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        BillCell1 * cell = [tableView dequeueReusableCellWithIdentifier:@"BillCell1"];
        if(!cell){
            cell = [[BillCell1 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BillCell1"];
        }
        [self addCellHeight:cell.cellHeight indexPath:indexPath];
        cell.backgroundImageView.transform = CGAffineTransformIdentity;
        [cell addRadius:0];
        cell.enableUnderLine = NO;
        if(indexPath.row == 0){
            cell.enableUnderLine = YES;
            cell.backgroundImage = [UIImage imageNamed:@"brokerage_bg02"];
            cell.backgroundImageView.transform = CGAffineTransformRotate(cell.backgroundImageView.transform, M_PI);
            [cell setMainTitle:@"08/2016" subTitle:@"日历" icon:[UIImage imageNamed:@"Calendar-month"]];
        }
        else{
           cell.enableUnderLine = NO;
            cell.backgroundImage = [UIImage imageNamed:@"brokerage_bg02"];
             [cell setMainTitle:@"八月份分佣情况" subTitle:@"1000" icon:nil];
        }
        return cell;
    }
    if(indexPath.section == 1){
        LinegraphCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LinegraphCell"];
        if(!cell){
            cell = [[LinegraphCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LinegraphCell"];
        }
        [self addCellHeight:cell.cellHeight indexPath:indexPath];
        [cell setRowDatas:@[@(5000),@(1000),@(5000),@(56),@(1)] colDatas:@[@(1),@(7),@(12),@(20),@(26)]];
        return cell;
    }
    
    if(indexPath.section == 2){
        BillCell2 * cell = [tableView dequeueReusableCellWithIdentifier:@"BillCell2"];
        if(!cell){
            cell = [[BillCell2 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BillCell2"];
        }
        cell.backgroundImageView.transform = CGAffineTransformIdentity;
        [cell.backgroundImageView addRadius:0];
        cell.enableUnderLine = NO;
        if(indexPath.row == 0){
            cell.backgroundImageView.image = [UIImage imageNamed:@"brokerage_bg02"];
            cell.enableUnderLine = YES;
            cell.backgroundImageView.transform = CGAffineTransformRotate(cell.backgroundImageView.transform, M_PI);
        }else{
            cell.backgroundImageView.image = [UIImage imageNamed:@"brokerage_bg02"];
            cell.enableUnderLine = NO;
        }
        [cell setMaintitle:@"无线端签到领绿豆" date:@"2016-08-01 08:30:30" detail:500];
        [self addCellHeight:cell.cellHeight indexPath:indexPath];
        return cell;
    }
    UITableViewCell * cell = [[UITableViewCell alloc] init];
    cell.textLabel.text = [NSString stringWithFormat:@"%ld组--->%ld行",indexPath.section,indexPath.row];
    [self addCellHeight:50 indexPath:indexPath];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [self cellHeightForIndexPath:indexPath];
}
#pragma mark - 懒加载 tableView
-(UITableView*)tableView{
    if(_tableView == nil){
        _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableView.sectionFooterHeight = 0;
        _tableView.sectionHeaderHeight = 0;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.contentInset = UIEdgeInsetsMake(39, 0, 0, 0);
        _tableView.backgroundColor = HexColor(@"#EEEEEE");
    }
    return _tableView;
}




@end
